public class Test {


    public static void main(String[] args) {
        String s="Hello, my name is John";
        int count=0;
        for (int i=0;i<s.length();i++)
        {
            if ((i == 0 || s.charAt(i - 1) == ' ') && s.charAt(i) != ' ') {
                count++;
            }
        }
        System.out.println(count);
    }
}
